var CustomerQnaWrite = function(){
	//이메일 호스트 옵션 버튼
	var qnaType=null;
	var qnaDetailType=null;
	var qnaTitle=null;
	var qnaContents=null;
	
}
CustomerQnaWrite.prototype={ 
	requestQna:function() {  
		var mj = new MJson(); 
		var cm = new ConnectionManager();
		mj.putPub(MJson.PUB.SID, "QA001");
		mj.putPub(MJson.PUB.SERVICENAME, "regQna"); 
		
		mj.putClient(MJson.CLIENT.USERID, document.globalObj.LOGIN_DATA.userId);  
		
		mj.putParameter("reg_id",document.globalObj.LOGIN_DATA.userId); 
		mj.putParameter(MJson.PARAMETER.QNATYPE, this.qnaType);
		mj.putParameter(MJson.PARAMETER.QNADETAILTYPE, this.qnaDetailType);
		mj.putParameter(MJson.PARAMETER.QNATITLE, this.qnaTitle);
		mj.putParameter(MJson.PARAMETER.QNACONTENTS, this.qnaContents);
		mj.putParameter(MJson.PARAMETER.QNASTATUS, "Y"); 
		
		cm.requestGet(mj.getJsonString(), function(jsonData) {
		console.log("success :: " + JSON.stringify(jsonData));
		if(mj.checkServiceResult(jsonData)) {
			console.log('성공:통신');
			//document.globalObj.LOGIN_DATA.isLogin = true;
			console.log(jsonData);  
			if(document.globalObj.LOGIN_DATA.loginAfterUrl != null)
				console.log('성공:Write QNA');
				$.mobile.changePage("qna.html");
			} else {
				console.log('실패:Write QNA'); 
			}
		}, function(e) {
			console.log('실패:통신');
			//alert("error :: " + JSON.stringify(e));
		});
	 },
	onPageShow:function(){
		console.log(this);
		qnaWrite=this;
		qnaRadio=$("input[type='radio']");
		
		qnaselect=$("#qnaselect");
		textTitle=$("#qnaTitle");
		textContents=$("#qnaContents");
		summitbtn= $("#summitbtn");
		$("input[type='radio']").bind( "change", function(event) {
			qnaWrite.qnaType=$("input[type='radio']:checked").val();
			console.log(qnaWrite.qnaType);
			if(qnaWrite.qnaType=="S"){
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect").append("<option value='B'>부킹</option>");
				$("#qnaselect").append("<option value='J'>조인룸</option>");
				$("#qnaselect").append("<option value='C'>동호회</option>");
				$("#qnaselect").append("<option value='P'>결제</option>");
				$("#qnaselect").append("<option value='M'>회원</option>");
				$("#qnaselect").append("<option value='E'>기타</option>");
 				$("#qnaselect").selectmenu('refresh');
			}else if(qnaWrite.qnaType=="C")
			{
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect option:eq(1)").remove();
				$("#qnaselect").append("<option value='G1'>골프장명 01</option>");
				$("#qnaselect").append("<option value='G2'>골프장명 02</option>");
				$("#qnaselect").append("<option value='G3'>골프장명 03</option>");
				$("#qnaselect").append("<option value='G4'>골프장명 04</option>"); 
 				$("#qnaselect").selectmenu('refresh');
			}
		});
		$(qnaselect).bind( "change", function(event) {
			qnaWrite.qnaDetailType=qnaselect.val();
  			console.log(qnaWrite.qnaDetailType);
		});
		$(summitbtn).bind('click', function(event) {
 			console.log("+++++++");
 			if(qnaWrite.qnaType==null){
 				console.log("qnaType null");
		  		return;
 			}
 			if(qnaWrite.qnaDetailType==null){
 				console.log("qnaDetailType null");
		  		return;
 			}
			if($(textTitle).val()==""){
				console.log("제목을 입력해 주세요");
				return;
		  	}
		  
			qnaWrite.qnaTitle=$(textTitle).val();
  
			console.log("타이틀 :: "+qnaWrite.qnaTitle+$(textTitle).val());
  
			if($(textContents).val()=="")
			{
				console.log("내용을 입력해 주세요");
				return;
			}
			qnaWrite.qnaContents=$(textContents).val();
  
			console.log("콘텐츠 :: "+qnaWrite.qnaContents);
			qnaWrite.requestQna();
		});
	}
}